package com.example.dellpc.myapplication;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.baoyz.swipemenulistview.SwipeMenuListView;

/**
 * Created by 刘智强 on 2016/8/9.
 */
public class MySwipeMenuListView extends SwipeMenuListView {

    private int startX;
    private int startY;
    public MySwipeMenuListView(Context context) {
        super(context);
    }

    public MySwipeMenuListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public MySwipeMenuListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


//    @Override
//    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
//                MeasureSpec.AT_MOST);
//        super.onMeasure(widthMeasureSpec, expandSpec);
//    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        switch (ev.getAction()){

            case MotionEvent.ACTION_DOWN:
                startX= (int) ev.getX();
                startY= (int) ev.getY();
           break;
            case MotionEvent.ACTION_MOVE:
                int dx= (int) (startX-ev.getX());
                int dy= (int) (startY-ev.getY());
                if (Math.abs(dx)>Math.abs(dy)){

                    return  true;
                }else{

                    return  false;
                }
        }
        return super.onInterceptTouchEvent(ev);
    }

}
